﻿using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Vtron.LEDCorrective.EDSDKWrapper;

namespace Vtron.LEDCorrective.Pages
{
    /// <summary>
    /// CameraParameters.xaml 的交互逻辑
    /// </summary>
    public partial class DatabaseSetting : UserControl
    {
        public DatabaseSetting()
        {
            InitializeComponent();
        }

        private void create_Btn_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.Title = "创建数据库";
            dlg.Filter = "数据库文件(*.mdb)|*.mdb";
            dlg.FileName = "*.mdb";
            dlg.RestoreDirectory = true;
            Nullable<bool> result = dlg.ShowDialog();
            if (result == true)
            {
                fileNameipCtroller_txt.Text = dlg.FileName.Substring(dlg.FileName.LastIndexOf('\\') + 1, dlg.FileName.Length - dlg.FileName.LastIndexOf('\\') - 1);
                filePath_txt.Text = dlg.FileName.Substring(0, dlg.FileName.LastIndexOf('\\'));
            }
        }

        private void loading_Btn_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Title = "载入数据库";
            dlg.Filter = "数据库文件(*.mdb)|*.mdb";
            Nullable<bool> result = dlg.ShowDialog();
            if (result == true)
            {
                fileNameipCtroller_txt.Text = dlg.FileName.Substring(dlg.FileName.LastIndexOf('\\') + 1, dlg.FileName.Length - dlg.FileName.LastIndexOf('\\') - 1);
                filePath_txt.Text = dlg.FileName.Substring(0, dlg.FileName.LastIndexOf('\\'));
            }
        }
    }
}
